import 'dart:ui';

class AMSizeFit {
  /// 基本信息
  // 物理分辨率
  static double physicalWidth;
  static double physicalHeight;

  // 屏幕宽高
  static double screenWidth;
  static double screenHeight;

  static double dpr;
  static double statusHeight;

  static double rpx;
  static double px;

  static void initialize({double standardSize = 750}) {
    // 1.获取手机物理分辨率
    physicalWidth = window.physicalSize.width;
    physicalHeight = window.physicalSize.height;

    // 2.获取dpr
    dpr = window.devicePixelRatio;

    // 3.获取屏幕宽
    screenWidth = physicalWidth/dpr;
    screenHeight = physicalHeight/dpr;

    // 4.状态栏高度
    statusHeight = window.padding.top;

    // 5.计算rpx大小
    rpx = screenWidth / standardSize;
    px = screenWidth / standardSize *2;
  }

  static double setRpx(double size) {
    return rpx * size;
  }

  static double setPx (double size) {
    return px * size;
  }

}